package com.foreknow.demo13;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        DBUtil dbUtil = new DBUtil();
        try {
            Connection conn = dbUtil.lianjie();
            ResultSet rs = dbUtil.chaxun("select * from employee where username = ? and password = ?","fender","123456");
            List<Employee> list= new ArrayList<>();
            while(rs.next()){
                Employee e = new Employee();
                e.setId(rs.getInt("id"));
                e.setUsername(rs.getString("username"));
                e.setPassword(rs.getString("password"));
                list.add(e);
            }
            for (Employee e:list
            ) {
                System.out.println(e.getId()+" "+e.getUsername()+" "+e.getPassword());
        } dbUtil.close();
    } catch (SQLException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
//
//        try {
//            dbUtil.lianjie();
//            dbUtil.dml("insert into Employee(UserName,Password) values ('haha','666666')");
//            dbUtil.close();
//        } catch (ClassNotFoundException e) {
//            e.printStackTrace();
//        } catch (SQLException e) {
//            e.printStackTrace();
//        }
//    }
    }
}
